﻿using HandyControl.Tools;
using MyMeeting.Extensions;
using MyMeeting.Service;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace MyMeeting.Views.Dialogs
{
    /// <summary>
    /// MeetDemoView.xaml 的交互逻辑
    /// </summary>
    public partial class MeetDemoView : UserControl
    {
        private IEventAggregator eg;
        public MeetDemoView(IEventAggregator eventAggregator)
        {
            InitializeComponent();
            this.eg = eventAggregator;
            this.Loaded += MeetDemoView_Loaded;
            //this.GetHandle
        }

        private void MeetDemoView_Loaded(object sender, RoutedEventArgs e)
        {
         
            eg.GetEvent<PubSubEvent<MeetDemoView>>().Publish(this);
            
          
        }

        public void Test()
        {
            this.VideoCtl.GetHandle();
        }

        private void BtnTest_Click(object sender, RoutedEventArgs e)
        {
            var s = 1;
        }

        private void Test_Click(object sender, RoutedEventArgs e)
        {
            var sp = new StackPanel();
            sp.Width = 500;
            sp.Height = 500;
           var render_ = new D3DImageSource(100,100, FrameFormat.ARGB32);

            // 将 D3DImage 绑定到 Image 控件
           var image = new System.Windows.Controls.Image
            {
                Stretch = Stretch.Fill

            };
            image.SetValue(Panel.ZIndexProperty, 20);
            image.Source = render_;
            image.Width = 100;
            image.Height = 100;




            // this.AddVisualChild(image);
            var btn = new Button();
            btn.Background = System.Windows.Media.Brushes.Yellow;
            btn.Content = "test";
            btn.Width = 100;
            btn.Height = 100;
            // this.Children.Add(btn);
            sp.Children.Add(btn);
            sp.Children.Add(image);
            this.VideoCtl.Children.Add(sp);
        }
        public void Test123()
        {
            var sp = new StackPanel();
            sp.Width = 500;
            sp.Height = 500;
            var render_ = new D3DImageSource(100, 100, FrameFormat.ARGB32);

            // 将 D3DImage 绑定到 Image 控件
            var image = new System.Windows.Controls.Image
            {
                Stretch = Stretch.Fill

            };
            image.SetValue(Panel.ZIndexProperty, 20);
            image.Source = render_;
            image.Width = 100;
            image.Height = 100;




            // this.AddVisualChild(image);
            var btn = new Button();
            btn.Background = System.Windows.Media.Brushes.Yellow;
            btn.Content = "test";
            btn.Width = 100;
            btn.Height = 100;
            // this.Children.Add(btn);
            sp.Children.Add(btn);
            sp.Children.Add(image);
            this.VideoCtl.Children.Add(sp);
        }
    }
}
